import time

import allure
from PO.page.page_login import PageLogin
from PO.page.page_me import PageMe
from utils.get_driver import UtilsDriver


class TestLogin():
    #TODO  初始化
    def setup_class(self):
        #TODO 获取登录页面对象
        self.login = PageLogin()
        # TODO 获取我的页面对象
        self.me=PageMe()

    #TODO 结束方法
    def teardown_class(self):
        with allure.step("后置方法：退出登录"):
            self.me.page_click_logout()
            self.login.base_get_allure_image()
        self.driver=UtilsDriver().quit_app_driver()

    def test_login01(self):

        with allure.step("测试步骤一：点击我的"):
            self.login.page_click_my()
            self.login.base_get_allure_image()

        with allure.step("测试步骤二：点击登录链接"):
            self.login.page_click_login()
            self.login.base_get_allure_image()

        with allure.step("测试步骤三：输入用户名"):
            self.login.page_input_username("18325539630")
            self.login.base_get_allure_image()

        with allure.step("测试步骤四：输入密码"):
            self.login.page_input_password("mike123456")
            self.login.base_get_allure_image()

        with allure.step("测试步骤五：点击登录"):
            self.login.page_click_login_btn()
            self.login.base_get_allure_image()

        with allure.step("测试步骤六：点击确定按钮"):
            self.login.page_click_ok_btn()
            self.login.base_get_allure_image()

        with allure.step("断言：获取昵称文本"):
            nickname=self.me.page_get_nickname_text()
            self.login.base_get_allure_image()

        assert nickname == 'mike-0809'



